
class Study{
    public String name;
    public void xie(){
        System.out.println(name+" 正在学习 ");   //一种形态
    }
}
class Student extends Study{
    public String color;
@Override
    public void xie(){
        System.out.println(name+" 正在写作业");
    }
}

class Teacher extends Study{
    public String gongHao;
    @Override  //这个是注解，就是要说明下面的这个方法要被重写，若个下面这个方法重写格式不对，会报错提示
    public void xie(){
        System.out.println(name+" 正在写教案");
    }
}



public class Test{
    public static void function(Study study1){

        study1.xie();
    }

    public static void main(String[] args) {
        Study study1=new Student();
        study1.name="学生";
        function(study1);
        Study study2=new Teacher();
        study2.name="老师";
        function(study2);
    }
    public static void main1(String[] args) {
       Study study =new Student();
       study.name="学者";
       study.xie();  //因为有重写，所以会出现动态绑定

    }
}

